<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <script src="__STATIC__/js/jquery.js"></script>
    <script src="__STATIC__/layui/layui.js"></script>
    <script type="text/javascript" src="__STATIC__/x-admin/js/xadmin.js"></script>
    <link rel="stylesheet" href="__STATIC__/x-admin/css/font.css">
    <link rel="stylesheet" href="__STATIC__/x-admin/css/xadmin.css">
    <link rel="stylesheet" href="__STATIC__/layui/css/layui.css">
</head>
<body>
<div style="height: 20px"></div>
<div class="x-nav">
      <span class="layui-breadcrumb">
        <a href="#">用户管理</a>
        <a href="#">学校管理</a>
        <a href="#">编辑学校</a>
      </span>
    <a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right" href="javascript:location.replace(location.href);" title="刷新">
        <i class="layui-icon" style="line-height:30px">ဂ</i></a>
</div>
<form  action="" id="teacher" onsubmit="return false" style="width:500px">
    <input type="hidden" name="id" value="{$info.id}">
    <div class="layui-form-item">
        <label class="layui-form-label">教师姓名</label>
        <div class="layui-input-block">
            <input type="text" name="teacher_name" value="{$info.teacher_name}" id="teacher_name" placeholder="教师姓名" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">所属学校</label>
        <div class="layui-input-block">
            <input type="text" readonly value="{$info.school.school_name}" placeholder="教师姓名" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">联系方式</label>
        <div class="layui-input-block">
            <input type="text" readonly value="{$info.teacher_phone}" name="teacher_phone" id="teacher_phone" placeholder="联系方式" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">职工号</label>
        <div class="layui-input-block">
            <input type="text" name="tid" value="{$info.tid}" id="tid" placeholder="职工号" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <div class="layui-input-block">
            <button class="layui-btn" id="update">立即保存</button>
            <button type="reset" class="layui-btn layui-btn-primary">重置</button>
        </div>
    </div>
</form>
<script>
    layui.use('form', function(){
        var form = layui.form;
    });
</script>
<script>
    $("#update").click(function(){
        var teacher_name = $("#teacher_name").val();
        if(!teacher_name){
            layer.msg('请输入教师姓名',{icon:5,time:2000});
            return;
        }
        $.ajax({
            url:"{:url('/teacher/teacherUpdate')}",
            type:"post",
            data:$("#teacher").serialize(),
            dataType:"json",
            success:function(res){
                if(res.code){
                    layer.msg(res.msg,{icon:1,time:2000},function(){
                        window.location.reload();
                    });
                    return;
                }else{
                    layer.msg(res.msg,{icon:5,time:2000});
                    return;
                }
            }
        });
    });
</script>
</body>
</html>